/****************************************************************************************
* Copyright (C): 
* @file : Matrix_Keyboard.cpp
* @brief : // 矩阵键盘函数实现
* @author : Zhou
* @email: : 
* @version : 1.0.0
* @date : 2023年9月19日
****************************************************************************************/

#include "Matrix_Keyboard.h"

const byte ROWS = 4;
const byte COLS = 3;

// byte rowPins[4] = {KEYPAD_ROW_1,KEYPAD_ROW_2,KEYPAD_ROW_3,KEYPAD_ROW_4};
// byte colPins[3] = {KEYPAD_COL_1,KEYPAD_COL_2,KEYPAD_COL_3};
byte rowPins[4] = {32, 19, 25, 26};
byte colPins[3] = {16, 17, 18};
char keyBoard[4][3] = { 
    {'1','2','3'},
    {'4','5','6'},
    {'7','8','9'},
    {'*','0','#'},
};

Keypad keypad = Keypad(makeKeymap(keyBoard), rowPins, colPins, ROWS, COLS);

// 获得按键
void xTaskKeyScan(void* xTaskkey)
{
  while(1)
  {
    char key = keypad.getKey();
      if(key != NO_KEY)
      {
          Serial.printf("按下了： %c  !\r\n", key);
        //   switch (key)
        //   {
        //   case '2': //cursor--
            
        //     break;
        //   case '8':
            
        //   default:
        //     break;
        //   }
      }
    vTaskDelay(50 / portTICK_PERIOD_MS);
  }
}